<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var sum = 0,
            average = 0;
        var num = prompt("请输入学生的数量");
        for (var n = 1; n <= num; n++) {
            var grass = prompt("请输入第" + n + "个同学的成绩");
            sum += parseInt(grass);
        }
        average = sum / num;
        alert("总成绩等于" + sum);
        alert("平均分等于" + average);
    </script>
</head>

<body>

</body>

</html>